package biz.obake.team.touchprotector.features.proximity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.app.c;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.g.c;

public class ProximityLightActivity extends c implements SharedPreferences.OnSharedPreferenceChangeListener, c.b {
    private TextView t;
    private TextView u;
    private SeekBar v;
    private long w = 0;
    private int x = 1000;

    class a implements SeekBar.OnSeekBarChangeListener {
        a(ProximityLightActivity proximityLightActivity) {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.r("proximity_light_threshold", i < seekBar.getMax() ? Integer.toString(((i + 1) * 200) / seekBar.getMax()) : "disabled");
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x0027 A[ADDED_TO_REGION] */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void G(java.lang.String r4) {
        /*
            r3 = this;
            int r0 = r4.hashCode()
            r1 = -1153419070(0xffffffffbb4038c2, float:-0.0029330705)
            r2 = 1
            if (r0 == r1) goto L_0x001a
            r1 = 780745080(0x2e893978, float:6.240247E-11)
            if (r0 == r1) goto L_0x0010
            goto L_0x0024
        L_0x0010:
            java.lang.String r0 = "ProximityLight.Lux"
            boolean r4 = r4.equals(r0)
            if (r4 == 0) goto L_0x0024
            r4 = 0
            goto L_0x0025
        L_0x001a:
            java.lang.String r0 = "proximity_light_threshold"
            boolean r4 = r4.equals(r0)
            if (r4 == 0) goto L_0x0024
            r4 = 1
            goto L_0x0025
        L_0x0024:
            r4 = -1
        L_0x0025:
            if (r4 == 0) goto L_0x002a
            if (r4 == r2) goto L_0x002a
            goto L_0x002d
        L_0x002a:
            r3.H()
        L_0x002d:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.features.proximity.ProximityLightActivity.G(java.lang.String):void");
    }

    /* access modifiers changed from: protected */
    public void H() {
        int parseInt = Integer.parseInt(biz.obake.team.touchprotector.g.c.c("ProximityLight.Lux"));
        long currentTimeMillis = System.currentTimeMillis();
        if (parseInt < this.x || currentTimeMillis - this.w > 1000) {
            this.x = parseInt;
            this.w = currentTimeMillis;
        }
        this.t.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_light_activity_sensor).replace("{0}", Integer.toString(this.x)));
        String l = biz.obake.team.touchprotector.g.a.l("proximity_light_threshold");
        if ("disabled".equals(l)) {
            this.u.setText(R.string.proximity_light_activity_threshold_disabled);
        } else {
            this.u.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_light_activity_threshold).replace("{0}", l));
        }
        int max = this.v.getMax();
        if (!"disabled".equals(l)) {
            int parseInt2 = Integer.parseInt(l);
            if (parseInt2 < 0) {
                parseInt2 = 0;
            } else if (parseInt2 > 200) {
                parseInt2 = 200;
            }
            max = ((max - 1) * parseInt2) / 200;
        }
        this.v.setProgress(max);
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.proximity_light_activity);
        this.t = (TextView) findViewById(R.id.sensor);
        this.u = (TextView) findViewById(R.id.thresholdText);
        this.v = (SeekBar) findViewById(R.id.thresholdBar);
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        this.v.setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
        biz.obake.team.touchprotector.g.a.i().unregisterOnSharedPreferenceChangeListener(this);
        biz.obake.team.touchprotector.g.c.h(this);
        biz.obake.team.touchprotector.g.c.f("ProximityLight.Preview", false);
    }

    public void onRamPrefsChanged(String str) {
        G(str);
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        this.v.setOnSeekBarChangeListener(new a(this));
        biz.obake.team.touchprotector.g.a.i().registerOnSharedPreferenceChangeListener(this);
        biz.obake.team.touchprotector.g.c.e(this);
        biz.obake.team.touchprotector.g.c.f("ProximityLight.Preview", true);
        H();
    }

    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
        G(str);
    }
}
